home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1990 / May 90 / MacApp.Tech$ 5⁄18⁄90 / 1304-External code info-May90 < prev    next >
Encoding:
Text File  |  1991-03-06  |  3.9 KB  |  85 lines  |  [TEXT/GEOL]

  1. Item    9397208                         17-May-90        07:03PDT
  2.  
  3. From:   KEMINK1                         Kemink, Joost
  4.  
  5. To:     POWERUP.ENG                     Power Up Software,PRT
  6.  
  7. cc:     MACAPP.TECH$                    MacApp Technical
  8.  
  9. Sub:    External code info
  10.  
  11. James,
  12.  
  13. Here is some more information on how the external code mechanism in Xenon
  14. works.
  15.  
  16. In Xenon, "black boxes" are connected together to form a data processing chain.
  17. Black boxes have zero or more inputs, zero or more outputs and parameters.
  18.  
  19. For every type of black box, an external code resource exists. Every external
  20. code resource is implemented in about the same way that HyperCard external code
  21. resources are implemented.
  22.  
  23. An external code resource implements a number (4 or so) of different routines,
  24. that are called from a case statement. The case statement determines which
  25. routine to call, by looking at a selector code in the parameter block.
  26.  
  27. To answer your question about classes that encapsulate the code behaviour:
  28.  
  29. At program startup time, all resources of type CUST (this is their type in
  30. Xenon) are scanned, and for each resource found, an object is created (call it
  31. a holder-object) that holds information about the resource such as its ID, name
  32. etc.
  33.  
  34. Whenever a new black box is created by the user, an object of another class
  35. (call it box-object) is created and 'linked' to one of the holder-objects, by
  36. filling one of its fields with a reference to the holder-object.
  37.  
  38. Then, when the black box needs to be calculated for example, the
  39. box-object.Calculate method is called, which in turn calls the
  40. holder-object.Calculate method. The holder-object.Calculate calls some services
  41. (also implemented by the holder-object) to load the code in memory, lock it
  42. etc. and then calls the external code after filling in a parameter block with
  43. the appropriate values.
  44. The holder-object.Calculate returns to the box-object.Calculate which then can
  45. do what it wants with the returned values.
  46.  
  47. It is important to note that, say for a signal chain with two sine generators,
  48. there are two box-objects but only one holder-object. Both box-objects refer to
  49. the same (sine) holder object. Since the generators can have parameters that
  50. differ (for example their frequency), the parameters are stored in the
  51. box-object. The parameters can be thought of as being 'specific' for each black
  52. box. On the other hand, the external code that implements the sine
  53. functionality is the same for both parameters. That's why these non-specific
  54. characteristics are stored in the holder-object.
  55.  
  56.  
  57. The communication between the external code and the application is done by
  58. filling in appropriate fields in a parameter block. A pointer to this parameter
  59. block is then passed as to the routine that calls the entrypoint of the
  60. external code.
  61. A better approach might be to just push the parameters on the stack and push a
  62. selector code as the last parameter and then call the entrypoint of the
  63. external code. This may require some assembly language code, but I think it can
  64. be done.
  65. I didn't try to do communication between two different code resources directly,
  66. basically because I didn't have an urgent need to do that in Xenon, also I
  67. think it adds another level of dificulty to the implementation of the mechanism
  68. in general. It would be a nice feature however.
  69.  
  70.  
  71. Since Xenon's source is not mine anymore, I can't provide you with any source
  72. code. But very useful information can be found in the following places:
  73.  
  74. • TechNote 135, Getting through CUSToms. I got a lot of the implementation
  75. ideas from this TechNote. It provides sample code.
  76. • TechNote 110, MPW: Writing Stand-Alone Code. Another great TechNote,
  77. especially the implementation of the window definiton procedure that shows the
  78. case-statement technique in determining which action to take, given a selector.
  79. • TechNote 256, Globals in Stand-Alone Code?
  80. • The Inside Macintosh chapters about the structure of WDEF's, CDEF's etc.
  81.  
  82.  
  83. Joost
  84.  
  85.